package com.yimi.yinhepda.adapter.RecycleAdapter;


import android.content.Context;
import android.view.View;

import com.yimi.yinhepda.R;
import com.pda.ym.base.CommonRecycleAdapter;
import com.pda.ym.base.CommonViewHolder;
import com.yimi.yinhepda.entity.bean.OfflineTaskEntity;

import java.util.List;

/**
 * @author lj
 */
public class OfflineLoadTaskCacheAdapter extends CommonRecycleAdapter<OfflineTaskEntity> {

    private Context mContext;
    private CommonViewHolder.onItemCommonClickListener mCommonClickListener;

    public OfflineLoadTaskCacheAdapter(Context context, List<OfflineTaskEntity> dataList, CommonViewHolder.onItemCommonClickListener commonClickListener) {
        super(context, dataList, R.layout.offline_load_task_item);
        this.mCommonClickListener = commonClickListener;
        this.mContext = context;
    }

    @Override
    public void bindData(CommonViewHolder holder, OfflineTaskEntity data, int position) {

        OfflineTaskEntity entity = dataList.get(position);
        holder.setText(R.id.taskCash_btn_CarCode, entity.getOfflineTaskNo());
        holder.setText(R.id.taskCash_btn_DeptCode, entity.getDestDeptName());
        holder.setText(R.id.tv_carNo, entity.getCarNo());
        holder.setText(R.id.taskCash_btn_pricenum, entity.getPriceNum() + "");

        if (entity.getLoadType() == 1) {
            holder.setText(R.id.tv_status, "已发车");
        } else {
            holder.setText(R.id.tv_status, "未发车");
        }

        holder.setCommonClickListener(mCommonClickListener);
        View view = holder.itemView;
        if (data.isCheck()) {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.yellow));
        } else if (data.getIsUpload() == 1) {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.green));
        } else {
            view.setBackgroundColor(mContext.getResources().getColor(R.color.white));
        }
    }
}
